package com.tanhua.dubbodb.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.model.domain.User;
import com.tanhua.dubbodb.mapper.UserMapper;
import com.tanhua.dubbointerface.api.UserApi;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UserApiImpl implements UserApi {
    @Autowired
    private UserMapper userMapper;
    public User findUserBymobile(String phone) {
        LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
        lqw.eq(User::getMobile,phone);
        User user = userMapper.selectOne(lqw);
        return user;
    }
    public long save(User user) {
        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }
}
